<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #editor {
            height: 500px;
            border: solid 1px red;
        }
        /* 数学公式|不显示问题 */
        line {
            stroke-width: 1px;
        }
    </style>
</head>

<body>
    <div id="editor" contenteditable="true"></div>
    <div id="rtfAppend" class="hidden-elem"></div>

    
    <script src="./rtfToHTML.min.js"></script>

    <script>
        // 监听粘贴功能
        document.getElementById('editor').addEventListener('paste', function (evt) {
            evt.preventDefault();
            const clipItems = evt.clipboardData.items|| window.clipboardData.items;
			
			//const clipItems = evt.dataTransfer.items;
			
			//console.log( "clipboardData==>",evt.clipboardData)
			//console.log( "====plain==>",evt.clipboardData.getData('text/plain'))
			//console.log( "====html==>",evt.clipboardData.getData('text/html'))
			let rtf=evt.clipboardData.getData('text/rtf')
			console.log( "====rtf==>",rtf)
		   
			rtfToHTML.fromString(rtf, (err, html) => {
			  console.log('-----------------------------------to html')
			  console.log(html)
			  document.getElementById('rtfAppend').innerHTML=html
            })
	   })

			
            
    </script>
</body>

</html>